# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: 线程练习.py
Author: kij
Create Date: 2021/3/11
-------------------------------------------------
"""
from threading import Thread,Lock,currentThread
import time

num = 0
mutex = Lock()


class MyThread(Thread):
	def run(self):
		global num
		time.sleep(1)

		if mutex.acquire(1):
			num = num + 1
			msg = self.name + ': num value is ' + str(num) +currentThread().getName()
			print(msg)
			mutex.release()


if __name__ == '__main__':
	for i in range(5):
		t = MyThread()
		t.start()
